


export default class UpMoveTipShow extends Laya.Script {
    /** @prop {name: addscore, tips:"addscore tip",type:Node} */
    private m_AddScoreTxt: Laya.FontClip;
    private m_IsShowing: boolean;
    private m_OrgPos: Laya.Vector2;

    onAwake() {
        this.m_AddScoreTxt = this.owner as Laya.FontClip;
        this.m_OrgPos = new Laya.Vector2();
        this.m_OrgPos.x = this.m_AddScoreTxt.x;
        this.m_OrgPos.y = this.m_AddScoreTxt.y;
        this.m_AddScoreTxt.visible = false;
    }

    onUpdate() {
        if (this.m_IsShowing) {
            this.m_AddScoreTxt.pos(this.m_OrgPos.x, this.m_AddScoreTxt.y - 1);
            if (Math.abs(this.m_AddScoreTxt.y - this.m_OrgPos.y) > 30) {
                this.m_IsShowing = false;
                this.m_AddScoreTxt.visible = false;
            }
        }
    }

    public Show(addscore: number) {
        if (addscore <= 0) return;
        this.m_AddScoreTxt.value = "+" + addscore.toString();
        this.m_AddScoreTxt.pos(this.m_OrgPos.x, this.m_OrgPos.y);
        this.m_IsShowing = true;
        this.m_AddScoreTxt.visible = true;
    }
}